/*
 *  Copyright 2023, SGE.  All right reserved.
 *
 *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGE CO.,
 *  LTD.  THE CONTENTS OF THIS FILE MAY NOT BE DISCLOSED TO THIRD
 *  PARTIES, COPIED OR DUPLICATED IN ANY FORM, IN WHOLE OR IN PART,
 *  WITHOUT THE PRIOR WRITTEN PERMISSION OF SGE CO., LTD.
 *
 *  
 *
 *  Edit History:
 *
 *    2023年02月17日 - Created by chenglun
 *
 */
#include <stdlib.h>
#include "monitorBizIf.h"

 OrderQueryOptionS *orderQueryCreateOption(const unsigned int offset, const unsigned int size)
 {
     //OrderQueryOptionS *p = new OrderQueryOptionS(offset, size);
     OrderQueryOptionS *p = (OrderQueryOptionS *)malloc(sizeof(OrderQueryOptionS));
     p->offset_ = offset;
     p->size_ = size;

     return p;
 }

 void orderQueryDestroyOption(OrderQueryOptionS *option)
 {
    if(option){
        //delete option;
        free(option);
    }
 }

 void orderQueryOptionSetOffset(const unsigned int offset, OrderQueryOptionS *option)
 {
    if(option){
        option->offset_ = offset;
    }
 }

 void orderQueryOptionSetSize(const unsigned int size, OrderQueryOptionS *option)
 {
    if(option){
        option->size_ = size;
    }
 }

//only for test
 unsigned int orderQueryOptionGetOffset(OrderQueryOptionS *option)
 {
    if(option){
        return option->offset_;
    }
    else{
        return -1;
    }
 }

 unsigned int orderQueryOptionGetSize(OrderQueryOptionS *option)
 {
    if(option){
        return option->size_;
    }
    else{
        return -1;
    }
 }

OrderQueryDataS *orderQueryCreateData(const int cnt)
{
    OrderQueryDataS *p = (OrderQueryDataS *)malloc(sizeof(OrderQueryDataS) + cnt * sizeof(OrderS));
    return p;
}

void orderQueryDestroyData(OrderQueryDataS *data)
{
    if(data){
        free(data);
    }
}

int orderQuery(const OrderQueryOptionS *option, OrderQueryDataS *result)
{
    if(!option || !result)
        return -1;
    result->totalCnt_ = 100;
    result->currentCnt_ = 1;
    //OrderS o{"12345678901234567890", 'b'};
    result->dataCollection_[0].orderNo_[0] = '3';
    result->dataCollection_[0].orderNo_[1] = '3';
    result->dataCollection_[0].orderNo_[2] = '\0';
    result->dataCollection_[0].buySellFlag_ = 'b';
    return 0;
}
